package com.tongna.tenant;

import org.hibernate.context.spi.CurrentTenantIdentifierResolver;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

/**
 * TenantDemo
 * 属性规定了一个合约，以使 Hibernate 能够解析出应用当前的 tenantId
 *
 * @author 张浩伟
 * @version 1.01 2018年02月09日
 */
public class CurrentTenantIdentifierResolverImpl implements CurrentTenantIdentifierResolver {

    private static Logger log = LoggerFactory.getLogger(CurrentTenantIdentifierResolverImpl.class);

    /**
     * @return
     * 应用当前的 tenantId
     */
    public String resolveCurrentTenantIdentifier() {
        return CurrentTenantIdentifierHolder.get();
    }

    public boolean validateExistingCurrentSessions() {
        return true;
    }
}
